package com.smart.community.region.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.community.region.entity.OwnerHousehold;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 业主房户关联Mapper接口
 * 
 * @author Wu.Liang
 * @since 2025-08-20
 * @version 1.0.0
 */
@Mapper
public interface OwnerHouseholdMapper extends BaseMapper<OwnerHousehold> {
    
    /**
     * 根据业主ID查询关联的房户列表
     * 
     * @param ownerId 业主ID
     * @return 业主房户关联列表
     */
    List<OwnerHousehold> selectByOwnerId(@Param("ownerId") Long ownerId);
    
    /**
     * 根据房户ID查询关联的业主列表
     * 
     * @param householdId 房户ID
     * @return 业主房户关联列表
     */
    List<OwnerHousehold> selectByHouseholdId(@Param("householdId") Long householdId);
    
    /**
     * 根据业主ID和房户ID查询关联记录
     * 
     * @param ownerId 业主ID
     * @param householdId 房户ID
     * @return 业主房户关联记录
     */
    OwnerHousehold selectByOwnerIdAndHouseholdId(@Param("ownerId") Long ownerId, @Param("householdId") Long householdId);
    
    /**
     * 根据房户ID查询主业主
     * 
     * @param householdId 房户ID
     * @return 主业主关联记录
     */
    OwnerHousehold selectPrimaryOwnerByHouseholdId(@Param("householdId") Long householdId);
    
    /**
     * 根据业主ID查询主业主的房户列表
     * 
     * @param ownerId 业主ID
     * @return 主业主房户关联列表
     */
    List<OwnerHousehold> selectPrimaryHouseholdsByOwnerId(@Param("ownerId") Long ownerId);
    
    /**
     * 根据社区ID查询业主房户关联列表
     * 
     * @param communityId 社区ID
     * @return 业主房户关联列表
     */
    List<OwnerHousehold> selectByCommunityId(@Param("communityId") Long communityId);
    
    /**
     * 根据楼栋ID查询业主房户关联列表
     * 
     * @param buildingId 楼栋ID
     * @return 业主房户关联列表
     */
    List<OwnerHousehold> selectByBuildingId(@Param("buildingId") Long buildingId);
    
    /**
     * 根据单元ID查询业主房户关联列表
     * 
     * @param unitId 单元ID
     * @return 业主房户关联列表
     */
    List<OwnerHousehold> selectByUnitId(@Param("unitId") Long unitId);
    
    /**
     * 删除业主的所有房户关联
     * 
     * @param ownerId 业主ID
     * @return 删除的记录数
     */
    int deleteByOwnerId(@Param("ownerId") Long ownerId);
    
    /**
     * 删除房户的所有业主关联
     * 
     * @param householdId 房户ID
     * @return 删除的记录数
     */
    int deleteByHouseholdId(@Param("householdId") Long householdId);
}
